<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>rat</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : April 1993</div>
    <p>
      <b>rat</b> -  Floating point rational approximation</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>[N,D]=rat(x [,tol])  </tt>
      </dd>
      <dd>
        <tt>y=rat(x [,tol])  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>x</b>
        </tt>: real  vector or matrix</li>
      <li>
        <tt>
          <b>n</b>
        </tt>: integer vector or matrix</li>
      <li>
        <tt>
          <b>d</b>
        </tt>: integer vector or matrix</li>
      <li>
        <tt>
          <b>y</b>
        </tt>: real vector or matrix</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
      <tt>
        <b>[N,D] = rat(x,tol)</b>
      </tt> returns two integer
    matrices so that <tt>
        <b>N./D</b>
      </tt> is close to<tt>
        <b>x</b>
      </tt> in the sense that
    <tt>
        <b>abs(N./D - X) &lt;= tol*abs(x)</b>
      </tt>. The rational approximations are
    generated by truncating continued fraction expansions.   
    <tt>
        <b>tol = 1.e-6*norm(X,1)</b>
      </tt> is the default.
    <tt>
        <b>y = rat(x,tol)</b>
      </tt> return the quotient <tt>
        <b>N./D</b>
      </tt>
    </p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

[n,d]=rat(%pi)
[n,d]=rat(%pi,1.d-12)
n/d-%pi
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="int.htm">
        <tt>
          <b>int</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="round.htm">
        <tt>
          <b>round</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
